#include <stdio.h>

int lowbit(int x)
{
    return x & (-x);  //x & (~x + 1)
}

int main()
{
    int n;
    scanf("%d", &n);
    while(n--)
    {
        int x;
        scanf("%d", &x);
        int res = 0;
        while(x) //开头的一定是1
        {
            x -= lowbit(x);  //每次减去一个1 
            res++;
        }
        printf("%d ", res);
    }
    return 0;
}